package com.tmpt.service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.tmpt.beans.A1TemplateTable;
import com.tmpt.dto.*;
import org.hibernate.HibernateException;

import com.googlecode.genericdao.search.Search;
import org.json.JSONObject;

public interface ITemplateService {
	public Result paginationBySearch(String paramJson, Map<String,Object> paramMap);
	public Result paginationBySearch4DynamicDS(A1TemplateTable templateTable, Map<String,String[]> paramMap1, String paramJson,
											   String _historyId ,Map<String,Object> paramMap) throws Exception;

	public A1TemplateTableDto getTemplateTable(String keyRandom);
	public Map<String, Object> getConditionMultiQuery(String keyRandom);
	
	public List<Map<String,Object>> queryReportBySearch(A1TemplateTableDto templateTableDto,String reportSqlString,List<Object> paramList);
	
	
	
	public Result addA1TemplateTable(A1TemplateTableDto a1TemplateTableDto);
	public Result addA1TemplateColumn2Table(A1TemplateColumnDto a1TemplateColumnDto, long tableId);
	public Result addA1TemplateCondition2Table(A1TemplateConditionDto a1TemplateConditionDto, long tableId);
	public Result addA1TemplateMultiQuery2Condition(A1TemplateConditionMultiQueryDto a1TemplateConditionMultiQueryDto, long conditionId);
	public Result addA1TemplateRightMenu2Table(A1TemplateRightMenuDto a1TemplateRightMenuDto, long tableId);
	
	
	
	public PaginationDto<A1TemplateTableDto> paginationA1TemplateTableListBySearch(Search search);
	public PaginationDto<A1TemplateColumnDto> paginationA1TemplateColumnListBySearch(Search search);
	public PaginationDto<A1TemplateConditionDto> paginationA1TemplateConditionListBySearch(Search search);
	public PaginationDto<A1TemplateConditionMultiQueryDto> paginationA1TemplateConditionMultiQueryListBySearch(Search search);
	public PaginationDto<A1TemplateRightMenuDto> paginationA1TemplateRightMenuListBySearch(Search search);
	
	/**
	 * 添加数据
	 * @param keydom
	 * @param jsonParam
	 * @return
	 */
	public Result addData(String keydom, String jsonParam) throws HibernateException, SQLException;

	/**
	 * 根据数据源执行addData
	 * @param a1TemplateTable
	 * @param json
	 * @param columnList
	 * @return
	 * @throws Exception
	 */
	public Result addData4DynamicDS(A1TemplateTable a1TemplateTable, JSONObject json,List<Map<String,Object>> columnList) throws Exception;

	/**
	 * 编辑数据
	 * @param keydom
	 * @param jsonParam
	 * @param id
	 * @return
	 */
	public Result editData(String keydom, String id, String jsonParam) throws HibernateException, SQLException;

	/**
	 * 根据数据源执行editData
	 * @param a1TemplateTable
	 * @param id
	 * @param json
	 * @param columnList
	 * @return
	 * @throws Exception
	 */
	public Result editData4DynamicDS(A1TemplateTable a1TemplateTable,String id, JSONObject json, List<Map<String,Object>> columnList) throws Exception;

	/**
	 * 伪删除
	 * @param parameters
	 * @return
	 */
	public Result removeData(String ... parameters);

	/**
	 * 多值选择，key-value形式; case status when 1 then '有效' when 0 then '无效' end
	 * @param keyRandom
	 * @return
	 */
	public String getTemplateTableColumnOptionJson(String keyRandom);

	/**
	 * 多值选择，key-value形式; case status when 1 then '有效' when 0 then '无效' end
	 * @param keyRandom
	 * @return
	 */
	public List<A1TemplateColumnDto> getTemplateTableColumnOptionList(String keyRandom);

	/**
	 * 自动加载模板列
	 * @param _id
	 * @return
	 */
	public Result loadColumn(String _id);

	/**
	 * 自动加载模板列(By a1TemplateTable datasource)
	 * @param templateTable
	 * @param tempColList
	 * @return
	 */
	public Result loadColumn4DynamicDS(A1TemplateTable templateTable, List<String> tempColList);

	//public Result addTemplateColumn(List<A1TemplateColumn> a1TemplateColumnList);
	
	/**
	 * Datagrid:模板生成菜单
	 * @return
	 */
	//public Result template2menu(long _templateTableId, long menu1Id, String menu2Name);
/*
	*//**
	 * 模板生成菜单,方法内部实现不同菜单的路由
	 * @param _templateTableId
	 * @param menu1Id
	 * @param pageType
	 * @param menu2Name
	 * @return
	 *//*
	public Result template2menuALL(long _templateTableId, long menu1Id, String pageType, String menu2Name);
	*/
	
	/**
	 * 图表：模板生成菜单 Single
	 * @param _templateColumnId
	 * @param menu1Id
	 * @param pageType
	 * @param menu2Name
	 * @param columnName
	 * @return
	 */
	//public Result template2menu4ChartSingle(long _templateColumnId, long menu1Id, String pageType, String menu2Name, String columnName);
	
	/**
	 * 通过OptionId 查找 option hidden column
	 * @param optionId
	 * @return
	 */
	public List<A1TemplateColumnOptionHidColDto> queryOptionHidColByOptionId(long optionId);


	//public Result addData4DynamicDSInner(A1TemplateTable a1TemplateTable,List<Map<String,Object>> columnList) throws Exception;
	//public Result editData4DynamicDSInner(A1TemplateTable a1TemplateTable,String id, List<Map<String,Object>> columnList) throws Exception;


	//public Result addTemplateColumnOption(A1TemplateColumnOption option, A1TemplateColumn a1TemplateColumn);

	/**
	 * 生成sql语句
	 * @return
	 * @throws Exception
	 */
	public Result genSql4DynamicDS(String paramJson) throws Exception;



	/**
	 * 查询option数据字典列表
	 * @param search
	 * @return
	 */
	public List<A1TemplateColumnOptionDataDto> queryOptionDataListBySearch(Search search);
}
